package com.scenic.rd_android.design_model.mvp.view;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.scenic.rd_android.R;
import com.scenic.rd_android.design_model.mvp.contact.AddTaskContact;

/**
 * A simple {@link Fragment} subclass.
 * Activities that contain this fragment must implement the
 * Use the {@link AddTaskFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class AddTaskFragment extends Fragment implements AddTaskContact.View {


    private EditText mEditTextTitle;
    private EditText mEditTextContent;

    public AddTaskFragment() {
        // Required empty public constructor
    }



    public static AddTaskFragment newInstance() {
        AddTaskFragment fragment = new AddTaskFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void onResume() {
        super.onResume();
        presenter.start();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_add, container, false);
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mEditTextTitle = (EditText) getView().findViewById(R.id.id_editText_fragment_title);
        mEditTextContent = (EditText)getView().findViewById(R.id.id_editText_fragment_content);
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    public void onDetach() {
        super.onDetach();

    }

    AddTaskContact.Presenter presenter;

    @Override
    public void setPresenter(AddTaskContact.Presenter presenter) {
        this.presenter = com.google.common.base.Preconditions.checkNotNull(presenter);
    }


    @Override
    public void setTitle(String title) {
        mEditTextTitle.setText(title);
    }

    @Override
    public void setContent(String content) {
        mEditTextContent.setText(content);
    }

    @Override
    public boolean isActive() {
        return isAdded();
    }

    @Override
    public void showEmptyTaskError() {

    }

    @Override
    public void showEditTask(String id) {

    }

    @Override
    public void showTasksList() {

    }
}
